import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'Routes.dart';

void main() {
  runApp(MyApp());
  SharedPreferences.setMockInitialValues({});
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      // designSize: Size(375, 812),
      builder: () => createApp(),
    );
  }
}

Widget createApp() {
  return MaterialApp(
    title: 'Flutter_ScreenUtil',
    debugShowCheckedModeBanner: false,
    localeListResolutionCallback: (locales, supportedLocales) {
      print(locales);
      return;
    },
    builder: (context, widget) {
      return MediaQuery(
        //Setting font does not change with system font size
        data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
        child: widget,
      );
    },
    routes: Routes.routes,
    initialRoute: RoutesString.splash,
    onGenerateRoute: (RouteSettings setting) {
      return MaterialPageRoute(builder: (ctx) {
        return Routes.routes[setting.name](ctx);
      });
    },
  );
}
